//
//  CYReInputField.m
//  CaiYun
//
//  Created by 今日信息科技 on 2017/7/14.
//  Copyright © 2017年 今日信息科技. All rights reserved.
//

#import "CYReInputField.h"
@interface CYReInputField(){
    ReInputBlock _myblock;

}
@property (nonatomic, strong) CYLabel *titleLBL;
@property (nonatomic, strong) CYButton *forgetPWD_Btn;
@property (nonatomic, strong) CYButton *reInputBtn;
@property (nonatomic, strong) CYView *midLine;
@property (nonatomic, strong) CYView *bottonLine;
@end
@implementation CYReInputField
- (instancetype)initWithColor:(UIColor *)color cornerRadius:(CGFloat)radius reInputBlock:(ReInputBlock)block{
 self = [super initWithColor:color];
    if (self) {
        _myblock = block;
        self.alpha = radius;
        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 5.0;
        self.titleLBL.hidden = self.midLine.hidden = self.forgetPWD_Btn.hidden = self.reInputBtn.hidden = self.bottonLine.hidden = NO;
    }
    return self;
}

- (CYLabel *)titleLBL{
    if (!_titleLBL) {
        _titleLBL = [[CYLabel alloc]initWithText:@"您输入的密码有误" size:AL(PT(32)) textcolor:ColorHex(0x333333)];
        [self addSubview:_titleLBL];
        
        WS(self)
        [_titleLBL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(weakSelf);
            make.top.equalTo(weakSelf).with.offset(AL(PT(50)));
            make.size.mas_equalTo(_titleLBL.bounds.size);
        }];
    }
    return _titleLBL;
}

- (CYView *)midLine{
    if (!_midLine) {
        _midLine = [[CYView alloc]initWithColor:ColorHex(0xe3e3e3)];
        [self addSubview:_midLine];
        
        WS(self)
        [_midLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLBL.mas_bottom).with.offset(AL(PT(28)));
            make.centerX.equalTo(weakSelf);
            make.size.mas_equalTo(CGSizeMake(AL(PT(380)), 0.5));
            
        }];
    }
    return _midLine;
}

- (CYView *)bottonLine{
    if (!_bottonLine) {
        _bottonLine = [[CYView alloc]initWithColor:ColorHex(0xe3e3e3)];
        [self addSubview:_bottonLine];
        
        WS(self)
        [_bottonLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_midLine.mas_bottom).with.offset(0);
            make.centerX.equalTo(weakSelf);
            make.size.mas_equalTo(CGSizeMake(0.5, AL(PT(70))));
            
        }];
    }
    return _bottonLine;
}

- (CYButton *)forgetPWD_Btn{
    if (!_forgetPWD_Btn) {
       _forgetPWD_Btn = [[CYButton alloc]initWithTitle:@"忘记密码" titleColor:ColorHex(0xff5b05) backgroundColor:[UIColor whiteColor] cornerRadius:0];
        _forgetPWD_Btn.titleLabel.font = [UIFont systemFontOfSize:AL(PT(28))];
        [_forgetPWD_Btn addTarget:self action:@selector(actionForForgetPassword) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_forgetPWD_Btn];
        
        WS(self)
        [_forgetPWD_Btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_midLine.mas_bottom).with.offset(0);
            make.centerX.equalTo(weakSelf).with.offset(-AL(PT(484 / 4.0)));
            make.bottom.equalTo(weakSelf.mas_bottom).with.offset(0);
            make.width.mas_equalTo(AL(PT(484 / 2.0)));
        }];
        
    }
    return _forgetPWD_Btn;
}
- (CYButton *)reInputBtn{
    if (!_reInputBtn) {
        _reInputBtn = [[CYButton alloc]initWithTitle:@"重新输入" titleColor:ColorHex(0xff5b05) backgroundColor:[UIColor whiteColor] cornerRadius:0];
        _reInputBtn.titleLabel.font = [UIFont systemFontOfSize:AL(PT(28))];
        [_reInputBtn addTarget:self action:@selector(actionForReInput) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_reInputBtn];
        
        WS(self)
        [_reInputBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_midLine.mas_bottom).with.offset(0);
            make.centerX.equalTo(weakSelf).with.offset(AL(PT(484 / 4.0)));
            make.bottom.equalTo(weakSelf.mas_bottom).with.offset(0);
            make.width.mas_equalTo(AL(PT(484 / 2.0)));
        }];
        
    }
    return _reInputBtn;
}
- (void)actionForForgetPassword{
    _myblock(@"忘记密码");
}
- (void)actionForReInput{
    _myblock(@"重新输入");
}
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
